#ifndef STAN_H
#define STAN_H
#include <QHash>
#include <QPointF>
#include <QString>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QGraphicsPixmapItem>
#include <QGraphicsEllipseItem>
#include <QList>
#include <QVBoxLayout>
#include <QMouseEvent>
#include <QDebug>
#include <list>
#include "production.h"
#include "shape.h"
#include "grammar.h"




const float accuracy=d;

class Stan
{
public:
    Stan(QGraphicsView* ,QVBoxLayout*);
    ~Stan();
    QList <Shape> shapes;
    QList <QPointF> positions;

    QList<QGraphicsView* > productionsList;
    QGraphicsView *graphicsView;
    QGraphicsScene *scene;
    QVBoxLayout *listLayout;
    int currentIndex;

    void updateScene();
    void updateList(int);
    void sceneClicked(const QPointF&);
    void productionClicked(const RShape&);



private:

    Grammar grammar;
    int find(const QPointF&);



};



class MyGraphicsView :public QGraphicsView
{
 public:

    MyGraphicsView(Stan *s,RShape r):QGraphicsView(){
        this->r=r;
        stan=s;

    };

    RShape r;
    Stan *stan;

protected:
    bool eventFilter(QObject *obj, QEvent *event)
    {
        if (event->type() == QEvent::MouseButtonPress)
        {
           // QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);

            RShape r= (static_cast<MyGraphicsView*>(obj))->r;

            stan->productionClicked(r);

            return true;
        } else {
            return false;
        }
    }

};

#endif // STAN_H
